home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #11 / Amiga Plus CD - 2004 - No. 11.iso / AmiSoft / Misc / emu / p-interp.lha / p-interp-0.5 / UnitIo.c < prev    next >
C/C++ Source or Header  |  2001-08-01  |  3KB  |  182 lines

  1. /*
  2.  
  3.   P-Code interpreter (to run the apple pascal system)
  4.   Copyright (C) 2000 Mario Klebsch
  5.  
  6.   This program is free software; you can redistribute it and/or modify
  7.   it under the terms of the GNU General Public License as published by
  8.   the Free Software Foundation; either version 2 of the License, or
  9.   (at your option) any later version.
  10.  
  11.   This program is distributed in the hope that it will be useful,
  12.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.   GNU General Public License for more details.
  15.  
  16.   You should have received a copy of the GNU General Public License
  17.   along with this program; if not, write to the Free Software
  18.   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  19.  
  20.   $Log: UnitIo.c,v $
  21.   Revision 1.7  2001/08/01 19:27:03  mario
  22.   Tippfehler korrigiert
  23.  
  24.   Revision 1.6  2001/06/16 17:21:42  mario
  25.   Eine fehlende Abhängigkeit vom Präprozessorsymbol TURTLEGRAPHICS
  26.   nachgetragen.
  27.  
  28.   Revision 1.5  2001/05/23 21:16:41  mario
  29.   Turtlegraphics wurde als eigener Prozess ausgelagert.
  30.  
  31.   Revision 1.4  2001/05/21 19:06:48  mario
  32.   Mode-Parameter bei den Disk-IO-Routinen entfernt
  33.  
  34.   Revision 1.3  2001/05/20 20:14:40  mario
  35.   Neues Gerät PRINTER: implementiert
  36.  
  37.   Revision 1.2  2001/05/20 13:12:02  mario
  38.   CVS-Idents und Logs eingefügt
  39.  
  40.  
  41. */
  42.  
  43. #ident "$Id: UnitIo.c,v 1.7 2001/08/01 19:27:03 mario Exp $";
  44.  
  45. #include <stdio.h>
  46.  
  47. #include "psystem.h"
  48. #include "Memory.h"
  49.  
  50. #include "Diskio.h"
  51. #include "Term.h"
  52.  
  53. void IoError(word Result)
  54. {
  55.   MemWr(IORSLT, Result);
  56. }
  57.  
  58. void UnitRead(word Unit, word Addr, Integer AddrOffset,
  59.           word Len, word Block, word Mode)
  60. {
  61.   IoError(0);
  62.   switch(Unit)
  63.     {
  64.     case 1:
  65.     case 2:
  66.       while (Len--)
  67.     {
  68.       char ch=TermRead();
  69.       if (Unit==1)
  70.         TermWrite(ch, 0);
  71.       MemWrByte(Addr, AddrOffset++, ch);
  72.     }
  73.       break;
  74.     case 4:
  75.     case 5:
  76.     case 9:
  77.     case 10:
  78.     case 11:
  79.     case 12:
  80.       DiskRead(Unit, Addr, AddrOffset, Len, Block);
  81.       break;
  82.     default:
  83.       IoError(2);
  84.       break;
  85.     }
  86. }
  87.  
  88. void PrinterWrite(byte ch, word Mode);
  89.  
  90. void UnitWrite(word Unit, word Addr, Integer AddrOffset,
  91.            word Len, word Block, word Mode)
  92. {
  93.   IoError(0);
  94.   switch(Unit)
  95.     {
  96.     case 1:
  97.     case 2:
  98.       while (Len--)
  99.     TermWrite(MemRdByte(Addr, AddrOffset++), Mode);
  100.       break;
  101.     case 4:
  102.     case 5:
  103.     case 9:
  104.     case 10:
  105.     case 11:
  106.     case 12:
  107.       DiskWrite(Unit, Addr, AddrOffset, Len, Block);
  108.       break;
  109.     case 6:
  110.       while (Len--)
  111.     PrinterWrite(MemRdByte(Addr, AddrOffset++), Mode);
  112.       break;
  113.     default:
  114.       IoError(2);
  115.       break;
  116.     }
  117. }
  118.  
  119. void PrinterClear(void);
  120. void GraphicsClear(void);
  121.  
  122. void UnitClear(word Unit)
  123. {
  124.   IoError(0);
  125.   switch(Unit)
  126.     {
  127.     case 1:
  128.     case 2:
  129.       break;
  130.     case 4:
  131.     case 5:
  132.     case 11:
  133.     case 12:
  134.       DiskClear(Unit);
  135.       break;
  136.     case 3:
  137.       PrinterClear();
  138. #ifdef TURTLEGRAPHICS
  139.       GraphicsClear();
  140. #endif
  141.       break;
  142.     case 6:
  143.       PrinterClear();
  144.       break;
  145.     default:
  146.       IoError(9);
  147.       break;
  148.     }
  149. }
  150.  
  151. void UnitStat(word Unit, word Addr, Integer Offset, word Dummy)
  152. {
  153.   IoError(0);
  154.   switch(Unit)
  155.     {
  156.     case 1:
  157.     case 2:
  158.       MemWr(Addr, TermStat());
  159.       break;
  160.     case 4:
  161.     case 5:
  162.     case 11:
  163.     case 12:
  164.       DiskStat(Unit);
  165.       break;
  166.     default:
  167.       IoError(9);
  168.       break;
  169.     }
  170. }
  171.  
  172. word UnitBusy(word Unit)
  173. {
  174.   IoError(0);
  175.   return(0);
  176. }
  177.  
  178. void UnitWait(word Unit)
  179. {
  180.   IoError(0);
  181. }
  182.